package o;

import java.security.NoSuchAlgorithmException;
import java.security.Provider;
import java.util.List;
import javax.annotation.Nullable;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import org.conscrypt.Conscrypt;

public class fwq extends fwy {
    private fwq() {
    }

    private Provider ˊ() {
        return Conscrypt.newProviderBuilder().provideTrustManager().build();
    }

    public void ॱ(SSLSocket sSLSocket, String str, List<fut> list) {
        if (Conscrypt.isConscrypt(sSLSocket)) {
            if (str != null) {
                Conscrypt.setUseSessionTickets(sSLSocket, true);
                Conscrypt.setHostname(sSLSocket, str);
            }
            Conscrypt.setApplicationProtocols(sSLSocket, (String[]) fwy.ˎ(list).toArray(new String[0]));
            return;
        }
        super.ॱ(sSLSocket, str, list);
    }

    @Nullable
    public String ˊ(SSLSocket sSLSocket) {
        if (Conscrypt.isConscrypt(sSLSocket)) {
            return Conscrypt.getApplicationProtocol(sSLSocket);
        }
        return super.ˊ(sSLSocket);
    }

    public SSLContext ॱ() {
        SSLContext instance;
        try {
            instance = SSLContext.getInstance("TLSv1.3", ˊ());
        } catch (Throwable e) {
            try {
                instance = SSLContext.getInstance("TLS", ˊ());
            } catch (NoSuchAlgorithmException e2) {
                throw new IllegalStateException("No TLS provider", e);
            }
        }
        return instance;
    }

    public static fwq ˏ() {
        try {
            Class.forName("org.conscrypt.Conscrypt");
            if (Conscrypt.isAvailable()) {
                return new fwq();
            }
            return null;
        } catch (ClassNotFoundException e) {
            return null;
        }
    }

    public void ˊ(SSLSocketFactory sSLSocketFactory) {
        if (Conscrypt.isConscrypt(sSLSocketFactory)) {
            Conscrypt.setUseEngineSocket(sSLSocketFactory, true);
        }
    }
}
